package com.example.mvvmdemo.viewmodel;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.example.mvvmdemo.BR;
import com.example.mvvmdemo.model.MVVMDataModel;

public class MVVMDataViewModel extends BaseObservable implements MVVMLoadDataCallback {

    private MVVMDataModel model;
    public MVVMDataViewModel(){
        model = new MVVMDataModel();
    }

    /**
     *必须添加@Bindable
     * @return
     */
    @Bindable
    public String getData(){
        return model.mDate;
    }

    public void loadUserData(){
        model.requestData(this);
    }

    @Override
    public void onSuccess(){
        notifyPropertyChanged(BR.data);
    }

    @Override
    public void onFailure(){

    }

}
